﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Autodesk.Revit.UI;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace HYElectricSetting
{
	public partial class CreatePairItemForm : System.Windows.Forms.Form
	{
		public CreatePairItemForm(string title, List<string> existedWire, List<string> selectWire, List<string> selectConduit)
		{
			this.InitializeComponent();
			this.formTitle = title;
			this.WireExistedItems = existedWire.ToList<string>();
			this.WireSelectItems = selectWire.ToList<string>();
			this.ConduitSelectItems = selectConduit.ToList<string>();
			this.WireResultItem = string.Empty;
			this.ConduitResultItem = string.Empty;
		}

		private void CreatePairItemForm_Load(object sender, EventArgs e)
		{
			base.Icon = Resource.YArchitechIcon;
			this.Text = this.formTitle;
			this.InitKeyCombox();
			this.InitValueCombox();
		}

		private void InitKeyCombox()
		{
			bool flag = false;
			this.cmbKey.Items.Clear();
			foreach (string text in this.WireSelectItems)
			{
				this.cmbKey.Items.Add(text);
				bool flag2 = !flag && !this.WireExistedItems.Contains(text);
				if (flag2)
				{
					this.cmbKey.SelectedItem = text;
					flag = true;
				}
			}
		}

		private void InitValueCombox()
		{
			this.cmbValue.Items.Clear();
			foreach (string item in this.ConduitSelectItems)
			{
				this.cmbValue.Items.Add(item);
			}
			bool flag = this.cmbValue.Items.Count > 0;
			if (flag)
			{
				this.cmbValue.SelectedIndex = 0;
			}
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			bool flag = this.cmbKey.SelectedItem == null || this.cmbKey.SelectedIndex < 0;
			if (flag)
			{
				TaskDialog.Show("盈建科提示", "导线截面积不能为空，请选择导线截面积。");
			}
			else
			{
				bool flag2 = this.cmbValue.SelectedItem == null || this.cmbValue.SelectedIndex < 0;
				if (flag2)
				{
					TaskDialog.Show("盈建科提示", "线管管径不能为空，请选择线管管径。");
				}
				else
				{
					this.WireResultItem = (string)this.cmbKey.SelectedItem;
					this.ConduitResultItem = (string)this.cmbValue.SelectedItem;
					bool flag3 = this.WireExistedItems.Contains(this.WireResultItem);
					if (flag3)
					{
						TaskDialog.Show("盈建科提示", "此导线截面积已存在，请重新选择。");
					}
					else
					{
						base.DialogResult = DialogResult.OK;
					}
				}
			}
		}

		private string formTitle;

		private List<string> WireExistedItems;

		private List<string> WireSelectItems;

		private List<string> ConduitSelectItems;

		public string WireResultItem;

		public string ConduitResultItem;
	}
}
